//
//  PPMediator+PPKeychain.m
//  PPMediator_Example
//
//  Created by ppss on 2021/6/18.
//  Copyright © 2021 ppss. All rights reserved.
//

#import "PPMediator+PPKeychain.h"

@implementation PPMediator (PPKeychain)
//数据是否存在钥匙串中
- (BOOL)PPMediator_ContainsKeychainForKey:(NSString *)key{
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
  
    paramsToSend[@"key"] = key;
    
    return [self performTarget:@"PPKeychainManager"
                 action:@"containsKeychainWithParams"
                 params:paramsToSend
      shouldCacheTarget:NO];
}

//存储数据
- (BOOL)PPMediator_SetKeychainForPassword:(id)password Key:(NSString *)key{
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
  
    paramsToSend[@"key"] = key;
    
    paramsToSend[@"password"] = password;

    return [self performTarget:@"PPKeychainManager"
                 action:@"setKeychainWithParams"
                 params:paramsToSend
      shouldCacheTarget:NO];
}

//获取数据
- (id)PPMediator_GetKeychainForKey:(NSString *)key{
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
  
    paramsToSend[@"key"] = key;
    
    return [self performTarget:@"PPKeychainManager"
                 action:@"getKeychainWithParams"
                 params:paramsToSend
      shouldCacheTarget:NO];
}

//移除数据
- (BOOL)PPMediator_RemoveKeychainForKey:(NSString *)key{
    NSMutableDictionary *paramsToSend = [[NSMutableDictionary alloc] init];
  
    paramsToSend[@"key"] = key;
    
    return [self performTarget:@"PPKeychainManager"
                 action:@"removeKeychainWithParams"
                 params:paramsToSend
      shouldCacheTarget:NO];
}
@end
